package com.moneytalks.blazepoc.models {
	import com.moneytalks.blazepoc.dto.UserDto;
	import com.moneytalks.blazepoc.services.NotebookServiceDelegate;
	import com.moneytalks.blazepoc.services.responders.AuthenticationResponder;
	
	[Bindable]
	public class ApplicationModel {
		
		public var currentState:String = "Login";
		public var user:UserDto;
		public var serviceMode:String = "mock";
		public var serviceUrlPrefix:String = "http://localhost:8080/blaze-poc-web";
		public var userMessage:String = "";
		
		private var _delegate:NotebookServiceDelegate;
		public function set delegate(d:NotebookServiceDelegate):void { _delegate = d; }
		
		public function isMockMode():Boolean {
			return (serviceMode == "mock");
		}
		public function login(username:String, password:String):void {
			_delegate.authenticate(username, password, new AuthenticationResponder(this));
		}
		public function showLogin():void {
			currentState = "Login";
		}
		public function showNotesView():void {
			currentState = "";
		}
		public function signOut():void {
			user = null;
			showLogin();
		}
	}
}